class Solution { //leetcode1512 好数对的数目
public:
    int numIdenticalPairs(vector<int>& nums) {
        unordered_map<int,int> hash;
        int ret=0;
        for(auto& e:nums)
        {
            hash[e]++;
        }
        for(auto& e:hash)
        {
            if(e.second>1)
            {
                ret+=(e.second)*(e.second-1)/2;
            }
        }
        return ret;
    }
};